<template>
  <view class="forget">
    <view class="content">
      <view class="main">
        <view class="tips">{{ $t('forget.hint') }}</view>
        <wInput style="margin-top: 100rpx" v-model="form.email" type="text" maxlength="30"
          :placeholder="$t('login.mobileNumber')"></wInput>
        <wInput v-model="form.password" type="password" :placeholder="$t('forget.newPwd')" isShowPass></wInput>
        <wInput v-model="form.verCode" type="text" maxlength="6" :placeholder="$t('forget.code')" ref="runCode" isShowCode
          @setCode="getVerCode"></wInput>
      </view>

      <wButton class="wbutton" :text="$t('forget.ResetPwd')" :rotate="isRotate" @click="startRePass"></wButton>
    </view>
  </view>
</template>

<script>
import wInput from '../../components/watch-login/watch-input.vue'
import wButton from '../../components/watch-login/watch-button.vue'

export default {
  components: {
    wInput,
    wButton
  },

  data() {
    return {
      form: {
        email: '',
        password: '',
        verCode: ''
      },
      isRotate: false //是否加载旋转
    }
  },

  computed: {
    validate() {
      if (this.form.password.length < 6) {
        this.$u.toast('密码至少为6位')
        return false
      }
      return true
    }
  },
  onReady() {
    uni.setNavigationBarTitle({
      title: this.$t("login.Forgot")
    });
  },
  methods: {

    async getVerCode() {
      // await this.sendForgetPasswordEmail(this.form.email)
      // this.$u.toast('发送成功')
      // this.$refs.runCode.$emit('runCode')
    },

    async startRePass() {
      // if (this.isRotate || !this.validate) return
      // this.isRotate = true
      // try {
      //   await this.forgetPassword({
      //     email: this.form.email,
      //     password: this.form.password,
      //     code: this.form.verCode
      //   })
      //   this.isRotate = false
      //   this.$u.toast('修改成功')
      //   setTimeout(() => {
      //     uni.reLaunch({
      //       url: '/pages/login/login'
      //     })
      //   }, 1000)
      // } catch {
      //   this.isRotate = false
      // }
    }
  }
}
</script>

<style>
@import url('../../components/watch-login/css/icon.css');
@import url('./css/main.css');
</style>

